package cn.edu.jxyy.mybatistest.test;

import cn.edu.jxyy.mybatistest.Utils.MyBatisUtils;
import cn.edu.jxyy.mybatistest.mapper.StudentMapper;
import cn.edu.jxyy.mybatistest.pojo.Student;
import org.apache.ibatis.session.SqlSession;

public class part15_2 {
    public static void updateStudentBySet()
    {
        SqlSession sqlSession = MyBatisUtils.getSession();
        Student student = new Student();
        student.setId(5);
        student.setName("张三");
        student.setAge(18);
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        int rows = studentMapper.updateStudentByset(student);
        if (rows > 0) {
            System.out.println("您成功修改了" + rows + "条数据！");
        } else {
            System.out.println("执行修改操作失败！！！");
        }
        sqlSession.commit();
        sqlSession.close();
    }
    public static void main(String[] args){
        updateStudentBySet();
    }
}
